package iit.projects.etaxi.model.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class City implements Serializable {

	private static final long serialVersionUID = -7507597932102665347L;
	
	/**
	 * <p>City Code. Used to uniquely identify a City</p> 
	 */
	private String code;
	
	/**
	 * <p>City Name</p>
	 */
	private String name;
	
	/**
	 * <p>Version Of the City</p>
	 */
	private Long version;
	
	/**
	 * <p>Sub Cities of City</p>
	 */
	private Set<SubCity> subcities = new HashSet<SubCity>(0);
	
	public City() {
	}
	
	public City(String code, String name){
		this.code = code;
		this.name = name;
	}
	
	public City(City city){
		this.code = city.code;
		this.name = city.name;
		this.version = city.version;
		this.subcities = city.subcities;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public Set<SubCity> getSubcities() {
		return subcities;
	}

	public void setSubcities(Set<SubCity> subcities) {
		this.subcities = subcities;
	}
	
	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		City other = (City) obj;
		if (getCode() == null) {
			if (other.getCode() != null)
				return false;
		} else if (!getCode().equals(other.getCode()))
			return false;
		return true;
	}

}
